package com.whosly.disclosure.early.handler.autoconfig.auto;

import com.whosly.api.autoconfigure.context.ISpringContextAware;
import com.whosly.api.autoconfigure.context.SpringContextAwareHolder;
import com.whosly.disclosure.early.handler.autoconfig.api.DefaultActionServiceImpl;
import com.whosly.disclosure.early.handler.autoconfig.api.IActionService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 默认初始化
 */
@Configuration(proxyBeanMethods = false)
public class DefaultDisclosureConfiguration {

    /**
     * SpringContextHolderExt 的默认实例化。
     * 如果已经存在 SpringContextHolderExt 的实例，则不初始化该操作
     */
    @Bean
    @ConditionalOnMissingBean(ISpringContextAware.class)
    public ISpringContextAware springContextAware() {
        SpringContextAwareHolder springContextAware = new SpringContextAwareHolder();

        return springContextAware;
    }

    /**
     * IActionService 的默认实例化。
     * 如果已经存在 IActionService 的实例，则不初始化该操作
     */
    @Bean
    @ConditionalOnMissingBean(IActionService.class)
    public IActionService actionService() {
        DefaultActionServiceImpl actionService = new DefaultActionServiceImpl();

        return actionService;
    }

}
